package eu.jpereira.trainings.designpatterns.structural.decorator.channel.decorator;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import eu.jpereira.trainings.designpatterns.structural.decorator.channel.SocialChannel;
import eu.jpereira.trainings.designpatterns.structural.decorator.channel.SocialChannelBuilder;
import eu.jpereira.trainings.designpatterns.structural.decorator.channel.SocialChannelProperties;
import eu.jpereira.trainings.designpatterns.structural.decorator.channel.SocialChannelPropertyKey;
import eu.jpereira.trainings.designpatterns.structural.decorator.channel.spy.TestSpySocialChannel;
public class WordCensorTest extends AbstractSocialChanneldDecoratorTest{
	
	@Test
	public void testCensor() {
		SocialChannelBuilder builder = createTestSpySocialChannelBuilder();
		
		SocialChannelProperties props = new SocialChannelProperties().putProperty(SocialChannelPropertyKey.NAME, TestSpySocialChannel.NAME);
		SocialChannel channel = builder.with(new WordCensor("this is a message")).getDecoratedChannel(props);

		channel.deliverMessage("this is a message");
		
		TestSpySocialChannel spyChannel = (TestSpySocialChannel) builder.buildChannel(props);

		assertEquals("### is a message", spyChannel.lastMessagePublished());
	}
}
